<?php
namespace Amis\form;

use Amis\Basics\AmisBasics;

class FormItem extends AmisBasics
{
    public function className($className)
    {
        $this->className = $className;
        return $this;
    }

    public function inputClassName($inputClassName)
    {
        $this->inputClassName = $inputClassName;
        return $this;
    }

    public function labelClassName($labelClassName)
    {
        $this->labelClassName = $labelClassName;
        return $this;
    }

    public function name($name)
    {
        $this->name = $name;
        return $this;
    }

    public function value($value)
    {
        $this->value = $value;
        return $this;
    }

    public function label($label)
    {
        $this->label = $label;
        return $this;
    }

    public function labelRemark($labelRemark)
    {
        $this->labelRemark = $labelRemark;
        return $this;
    }

    public function description($description)
    {
        $this->description = $description;
        return $this;
    }

    public function placeholder(string $placeholder)
    {
        $this->placeholder = $placeholder;
        return $this;
    }

    public function inline(bool $inline)
    {
        $this->inline = $inline;
        return $this;
    }

    public function submitOnChange(bool $submitOnChange)
    {
        $this->submitOnChange = $submitOnChange;
        return $this;
    }

    public function disabled(bool $disabled)
    {
        $this->disabled = $disabled;
        return $this;
    }

    public function disabledOn($disabledOn)
    {
        $this->disabledOn = $disabledOn;
        return $this;
    }

    public function visible($visible)
    {
        $this->visible = $visible;
        return $this;
    }

    public function visibleOn($visibleOn)
    {
        $this->visibleOn = $visibleOn;
        return $this;
    }

    public function required(bool $required)
    {
        $this->required = $required;
        return $this;
    }

    public function requiredOn($requiredOn)
    {
        $this->requiredOn = $requiredOn;
        return $this;
    }

    public function validations($validations)
    {
        $this->validations = $validations;
        return $this;
    }

    public function validateApi($validateApi)
    {
        $this->validateApi = $validateApi;
        return $this;
    }

    /**
     * autoUpdate    Object        自动填充配置
     * autoUpdate.api    api        自动填充数据接口地址
     * autoUpdate.mapping    Object        自动填充字段映射关系
     * autoUpdate.showToast    boolean        是否展示数据格式错误提示，默认为 false
     * @param string $api
     * @param array $mapping
     * @param bool $showToast
     * @return $this
     */
    public function autoUpdate(string $api, array $mapping, bool $showToast)
    {
        $this->autoUpdate['api']       = $api;
        $this->autoUpdate['mapping']   = $mapping;
        $this->autoUpdate['showToast'] = $showToast;
        return $this;
    }
}